# -*- coding: utf-8 -*-
"""
@ Created on 2024-07-31 11:10
---------
@summary: 
---------
@author: XiaoBai
"""

print("十二十".isdigit())
import re


def convert_to_halfwidth(text):
    # 定义正则表达式模式，匹配全角数字
    pattern = re.compile('[０１２３４５６７８９]')

    # 使用正则表达式替换函数将全角数字替换为半角数字
    def replace(match):
        fullwidth_char = match.group(0)
        print(fullwidth_char)
        if fullwidth_char.isdigit():
            return chr(ord(fullwidth_char) - 0xfee0)
        return ''

    # 调用 sub 方法进行替换
    converted_text = pattern.sub(replace, text)
    return converted_text


# 示例用法
# text = "１２３４５６７８９０"
text = "1"
converted_text = convert_to_halfwidth(text)
print(converted_text)  # 输出: "1234567890"
